#include "QColor.h"

EXPORT_C CQColor::CQColor()
:m_Red(0),
 m_Green(0),
 m_Blue(0),
 m_Alpha(0xFF)
{
}

EXPORT_C CQColor::~CQColor()
{
	m_Red = 0;
	m_Green = 0;
	m_Blue = 0;
	m_Alpha = 0xFF;
}
EXPORT_C CQColor::CQColor(QUINT32 aColor)
{
    m_Red = (QUINT8)(aColor & 0x000000FF);
    m_Green = (QUINT8)((aColor >> 8) & 0x000000FF);
    m_Blue = (QUINT8)((aColor >> 16) & 0x000000FF);
    m_Alpha = (QUINT8)((aColor >> 24) & 0x000000FF);
}

EXPORT_C CQColor::CQColor(const CQColor& aColor)
{
    m_Red = aColor.m_Red;
    m_Green = aColor.m_Green;
    m_Blue = aColor.m_Blue;
    m_Alpha = aColor.m_Alpha;
}

EXPORT_C CQColor::CQColor(CQColor& aColor)
{
    m_Red = aColor.m_Red;
    m_Green = aColor.m_Green;
    m_Blue = aColor.m_Blue;
    m_Alpha = aColor.m_Alpha;
}
EXPORT_C CQColor::CQColor(QUINT8 aRed, QUINT8 aGreen, QUINT8 aBlue, QUINT8 aAlpha)
:m_Red(aRed), m_Green(aGreen), m_Blue(aBlue), m_Alpha(aAlpha) 
{
}

EXPORT_C CQColor::CQColor(QUINT32 aInternalValue, QUINT8 aAlpha)
{
	 m_Alpha = aAlpha;
	m_Red = (QUINT8)(aInternalValue & 0x000000FF);
	m_Green = (QUINT8)((aInternalValue >> 8) & 0x000000FF);
	m_Blue = (QUINT8)((aInternalValue >> 16) & 0x000000FF);	 
}

EXPORT_C void CQColor::SetRed(QUINT8 aRed)
{
    m_Red = aRed;
}

EXPORT_C void CQColor::SetGreen(QUINT8 aGreen)
{
    m_Green = aGreen;
}

EXPORT_C void CQColor::SetBlue(QUINT8 aBlue)
{
    m_Blue = aBlue;
}

EXPORT_C void CQColor::SetAlpha(QUINT8 aAlpha)
{
    m_Alpha = aAlpha;
}

EXPORT_C CQColor& CQColor::operator=(const CQColor& aColor)
{
    if(&aColor == this)
    {
        return *this;
    }
    m_Red = aColor.m_Red;
    m_Green = aColor.m_Green;
    m_Blue = aColor.m_Blue;
    m_Alpha = aColor.m_Alpha;
    return *this;
}
EXPORT_C QBOOL CQColor::operator==(const CQColor& aColor)
{

    if (m_Red == aColor.m_Red
		&& m_Green == aColor.m_Green
        && m_Blue == aColor.m_Blue
        /*&& m_Alpha == aColor.m_Alpha*/)
    {
	    return QTRUE;
    }
	else
	{
	    return QFALSE;
	}
}
EXPORT_C CQColor& CQColor::operator+( const CQColor& aColor )
{
	m_Red += aColor.m_Red;
	m_Green += aColor.m_Green;
	m_Blue += aColor.m_Blue;
	return *this;
}

EXPORT_C CQColor& CQColor::operator-( const CQColor& aColor )
{
	m_Red -= aColor.m_Red;
	m_Green -= aColor.m_Green;
	m_Blue -= aColor.m_Blue;
	return *this;
}
EXPORT_C QUINT32 CQColor::Value() const
{
    QUINT32 color;
    color = m_Red + (m_Green << 8) + (m_Blue << 16) + (m_Alpha << 24);
    return color;
}
